package com.zhongketech.sunflower.transport.model;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import de.greenrobot.dao.AbstractDaoMaster;
import de.greenrobot.dao.identityscope.IdentityScopeType;

import com.zhongketech.sunflower.transport.model.UserDao;
import com.zhongketech.sunflower.transport.model.SchoolDao;
import com.zhongketech.sunflower.transport.model.ClassesDao;
import com.zhongketech.sunflower.transport.model.ParentsDao;
import com.zhongketech.sunflower.transport.model.AuthorizationsDao;
import com.zhongketech.sunflower.transport.model.SmsCodeDao;
import com.zhongketech.sunflower.transport.model.MyRequestDao;
import com.zhongketech.sunflower.transport.model.RequestDao;
import com.zhongketech.sunflower.transport.model.MyContactsDao;
import com.zhongketech.sunflower.transport.model.ContactDao;
import com.zhongketech.sunflower.transport.model.MyApplicationsInfoDao;
import com.zhongketech.sunflower.transport.model.MySupervisionDao;
import com.zhongketech.sunflower.transport.model.SupervisionDao;
import com.zhongketech.sunflower.transport.model.TimesDao;
import com.zhongketech.sunflower.transport.model.EyeProtectDao;
import com.zhongketech.sunflower.transport.model.ApplicationControlDao;
import com.zhongketech.sunflower.transport.model.ApplicationsDao;
import com.zhongketech.sunflower.transport.model.CallDao;
import com.zhongketech.sunflower.transport.model.SmsDao;
import com.zhongketech.sunflower.transport.model.ScreenLockDao;
import com.zhongketech.sunflower.transport.model.NetworkDao;
import com.zhongketech.sunflower.transport.model.SpecialNumsDao;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * Master of DAO (schema version 2): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
    public static final int SCHEMA_VERSION = 2;

    /** Creates underlying database table using DAOs. */
    public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) {
        UserDao.createTable(db, ifNotExists);
        SchoolDao.createTable(db, ifNotExists);
        ClassesDao.createTable(db, ifNotExists);
        ParentsDao.createTable(db, ifNotExists);
        AuthorizationsDao.createTable(db, ifNotExists);
        SmsCodeDao.createTable(db, ifNotExists);
        MyRequestDao.createTable(db, ifNotExists);
        RequestDao.createTable(db, ifNotExists);
        MyContactsDao.createTable(db, ifNotExists);
        ContactDao.createTable(db, ifNotExists);
        MyApplicationsInfoDao.createTable(db, ifNotExists);
        MySupervisionDao.createTable(db, ifNotExists);
        SupervisionDao.createTable(db, ifNotExists);
        TimesDao.createTable(db, ifNotExists);
        EyeProtectDao.createTable(db, ifNotExists);
        ApplicationControlDao.createTable(db, ifNotExists);
        ApplicationsDao.createTable(db, ifNotExists);
        CallDao.createTable(db, ifNotExists);
        SmsDao.createTable(db, ifNotExists);
        ScreenLockDao.createTable(db, ifNotExists);
        NetworkDao.createTable(db, ifNotExists);
        SpecialNumsDao.createTable(db, ifNotExists);
    }
    
    /** Drops underlying database table using DAOs. */
    public static void dropAllTables(SQLiteDatabase db, boolean ifExists) {
        UserDao.dropTable(db, ifExists);
        SchoolDao.dropTable(db, ifExists);
        ClassesDao.dropTable(db, ifExists);
        ParentsDao.dropTable(db, ifExists);
        AuthorizationsDao.dropTable(db, ifExists);
        SmsCodeDao.dropTable(db, ifExists);
        MyRequestDao.dropTable(db, ifExists);
        RequestDao.dropTable(db, ifExists);
        MyContactsDao.dropTable(db, ifExists);
        ContactDao.dropTable(db, ifExists);
        MyApplicationsInfoDao.dropTable(db, ifExists);
        MySupervisionDao.dropTable(db, ifExists);
        SupervisionDao.dropTable(db, ifExists);
        TimesDao.dropTable(db, ifExists);
        EyeProtectDao.dropTable(db, ifExists);
        ApplicationControlDao.dropTable(db, ifExists);
        ApplicationsDao.dropTable(db, ifExists);
        CallDao.dropTable(db, ifExists);
        SmsDao.dropTable(db, ifExists);
        ScreenLockDao.dropTable(db, ifExists);
        NetworkDao.dropTable(db, ifExists);
        SpecialNumsDao.dropTable(db, ifExists);
    }
    
    public static abstract class OpenHelper extends SQLiteOpenHelper {

        public OpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory, SCHEMA_VERSION);
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
            createAllTables(db, false);
        }
    }
    
    /** WARNING: Drops all table on Upgrade! Use only during development. */
    public static class DevOpenHelper extends OpenHelper {
        public DevOpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory);
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
            dropAllTables(db, true);
            onCreate(db);
        }
    }

    public DaoMaster(SQLiteDatabase db) {
        super(db, SCHEMA_VERSION);
        registerDaoClass(UserDao.class);
        registerDaoClass(SchoolDao.class);
        registerDaoClass(ClassesDao.class);
        registerDaoClass(ParentsDao.class);
        registerDaoClass(AuthorizationsDao.class);
        registerDaoClass(SmsCodeDao.class);
        registerDaoClass(MyRequestDao.class);
        registerDaoClass(RequestDao.class);
        registerDaoClass(MyContactsDao.class);
        registerDaoClass(ContactDao.class);
        registerDaoClass(MyApplicationsInfoDao.class);
        registerDaoClass(MySupervisionDao.class);
        registerDaoClass(SupervisionDao.class);
        registerDaoClass(TimesDao.class);
        registerDaoClass(EyeProtectDao.class);
        registerDaoClass(ApplicationControlDao.class);
        registerDaoClass(ApplicationsDao.class);
        registerDaoClass(CallDao.class);
        registerDaoClass(SmsDao.class);
        registerDaoClass(ScreenLockDao.class);
        registerDaoClass(NetworkDao.class);
        registerDaoClass(SpecialNumsDao.class);
    }
    
    public DaoSession newSession() {
        return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
    }
    
    public DaoSession newSession(IdentityScopeType type) {
        return new DaoSession(db, type, daoConfigMap);
    }
    
}
